package com.ruoyi.module.expertTeam.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.expertTeam.domain.ExpertTeam;
import com.ruoyi.module.expertTeam.service.IExpertTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家团Controller
 * 
 * @author yqq
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/api/expertTeam")
public class ExpertTeamController extends BaseController
{
    @Autowired
    private IExpertTeamService expertTeamService;

    /**
     * 查询专家团列表
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpertTeam expertTeam)
    {
        startPage();
        List<ExpertTeam> list = expertTeamService.selectExpertTeamList(expertTeam);
        return getDataTable(list);
    }

    /**
     * 导出专家团列表
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:export')")
    @Log(title = "专家团", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpertTeam expertTeam)
    {
        List<ExpertTeam> list = expertTeamService.selectExpertTeamList(expertTeam);
        ExcelUtil<ExpertTeam> util = new ExcelUtil<ExpertTeam>(ExpertTeam.class);
        util.exportExcel(response, list, "专家团数据");
    }

    /**
     * 获取专家团详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:query')")
    @GetMapping(value = "/{expertId}")
    public AjaxResult getInfo(@PathVariable("expertId") Long expertId)
    {
        return success(expertTeamService.selectExpertTeamByExpertId(expertId));
    }

    /**
     * 新增专家团
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:add')")
    @Log(title = "专家团", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ExpertTeam expertTeam)
    {
        return toAjax(expertTeamService.insertExpertTeam(expertTeam));
    }

    /**
     * 修改专家团
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:edit')")
    @Log(title = "专家团", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody ExpertTeam expertTeam)
    {
        return toAjax(expertTeamService.updateExpertTeam(expertTeam));
    }

    /**
     * 删除专家团
     */
    @PreAuthorize("@ss.hasPermi('api:expertTeam:remove')")
    @Log(title = "专家团", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{expertId}")
    public AjaxResult remove(@PathVariable Long expertId)
    {
        return toAjax(expertTeamService.deleteExpertTeamByExpertId(expertId));
    }
}
